import 'package:flutter/material.dart';
import 'package:flutter_base/base/widget/base_get_builder.dart';
import 'package:flutter_base/config/app_color.dart';
import 'package:flutter_base/generated/assets.dart';
import 'package:flutter_base/pages/mine/test_history/test_history_list/test_history_list_view.dart';
import 'package:flutter_base/widgets/appbar/common_app_bar.dart';
import 'package:flutter_base/widgets/image/auto_image.dart';
import 'package:flutter_base/widgets/tab/common_two_tab_bar.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get/get.dart';

import 'test_history_logic.dart';

class TestHistoryPage extends StatelessWidget {
  final logic = Get.put(TestHistoryLogic());

  TestHistoryPage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return BaseGetBuilder<TestHistoryLogic>(
      appBar: const CommonAppBar(
        title: 'My Review',
        // showLeft: true,
        // showRight: false,
        backgroundColor: Colors.transparent,
      ),
      extendBodyBehindAppBar: true,
      builder: (_) {
        return Container(
          decoration: const BoxDecoration(
            gradient: LinearGradient(
              begin: Alignment.topCenter,
              end: Alignment.bottomCenter,
              colors: [
                Color(0xFFB7FFDD),
                Color(0xFFF5F7FA),
                Color(0xFFF5F7FA),
              ],
              stops: [0.0, 0.3125, 1.0],
            ),
          ),
          child: Column(
            children: [
              SizedBox(
                height: kToolbarHeight + ScreenUtil().statusBarHeight + 14.w,
              ),
              // 选项卡
              _buildTabBar(),
              10.verticalSpaceFromWidth,
              // 列表内容
              Expanded(
                  child: MediaQuery.removePadding(
                removeTop: true,
                context: context,
                child: TabBarView(
                  controller: logic.tabController,
                  children: [
                    // Container(),
                    // Container(),
                    TestHistoryListPage(type: 1),
                    TestHistoryListPage(type: 0),
                    // _buildLoginContent(),
                    // _buildRegisterContent(),
                  ],
                ),
              )),
            ],
          ),
        );
      },
    );
  }

  // 构建选项卡
  Widget _buildTabBar() {
    return Padding(
        padding: EdgeInsets.symmetric(horizontal: 27.w),
        child: CommonTwoTabBar(
            tabController: logic.tabController,
            tabs: const ['Completed', 'Not Completed']));
  }
}
